{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
<input type="hidden" name='id' id='id' value="{$info.id}" />
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
				<!-- form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">等级名称：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="name" value="{$info.name}" name="name" class="form-control" placeholder="请输入等级名称"  >
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">自动升级上传个数：</label>
						<div class="col-sm-9">
							<input type="number" autocomplete="off" id="up_num"  value="{$info.up_num}"   name="up_num" class="form-control" placeholder="请输入数量"  >
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">有效期：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="expiry"  value="{$info.expiry}"   name="work_years" class="form-control" placeholder="请输入有效期"  >
						</div>
					</div>

					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">有效期单位：</label>
						<div class="col-sm-9">
							<input   name="unit" value="1" type="radio" {if condition="$info.unit eq '1'"}checked{/if} title="月">
							<input   name="unit" value="2" type="radio" {if condition="$info.unit eq '2'"}checked{/if} title="年">
						</div>
					</div>


					<!--<div class="form-group">
						<label class="col-sm-2 control-label">创建时间：</label>
						<div class="col-sm-9">
							<input disabled type="text" autocomplete="off" value="{if condition="$info.createtime neq ''"}{$info.createtime|date='Y-m-d H:i:s'}{/if}" name="createtime"  placeholder="请输入创建时间" class="form-control" id="createtime">
						</div>
					</div>-->
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">状态：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['status'])){ $info['status'] = '0'; }; ?>
							<input name="status" value="1" type="radio" {if condition="$info.status eq '1'"}checked{/if} title="开启">
							<input name="status" value="0" type="radio" {if condition="$info.status eq '0'"}checked{/if} title="关闭">
						</div>
					</div>

					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">招商代理：</label>
						<div class="col-sm-9">
							<input  lay-filter="radioFilter"  name="is_zs" value="1" type="radio" {if condition="$info.is_zs eq '1'"}checked{/if} title="是">
							<input   lay-filter="radioFilter"    name="is_zs" value="0" type="radio" {if condition="$info.is_zs eq '0'"}checked{/if} title="否">
						</div>
					</div>
					<input type="hidden" id="is_zs_val" value="{$info.is_zs}">

					<div class="form-group"  id="zs_price_div" >
						<label class="col-sm-2 control-label">加盟费用：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="zs_price"  value="{$info.zs_price}"   name="zs_price" class="form-control" placeholder="请输入金额"  >
						</div>
					</div>
					<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.update()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script>

layui.use(['form'],function(){
	var is_zs_val=$("#is_zs_val").val();
	if(is_zs_val==0){
		$("#zs_price_div").hide();
	}
	var form = layui.form;

	// 绑定radio的click事件
	form.on('radio(radioFilter)', function(data){
		// data是一个包含当前radio的所有数据的对象
		var is_zs_val=data.value;
		if(is_zs_val==0){
			$("#zs_price_div").hide();
		}else{
			$("#zs_price_div").show();
		}
		console.log(data.value); // 被点击的radio的value值
		console.log(data.title); // 被点击的radio的显示文本
		// 在这里编写你的逻辑代码
	});
});
laydate.render({elem: '#createtime',type: 'datetime',trigger:'click'});
laydate.render({elem: '#expiretime',type: 'datetime',trigger:'click'});

var CodeInfoDlg = {
	CodeInfoData: {},
	validateFields: {
		status: {
			validators: {
				notEmpty: {
					message: '状态不能为空'
	 			},
	 		}
	 	},
	 }
}

CodeInfoDlg.collectData = function () {
	this.set('name').set('expiry').set('id').set('up_num').set('zs_price');
};

CodeInfoDlg.update = function () {

	 this.clearData();
	 this.collectData();
	 if (!this.validate()) {
	 	return;
	 }
	var unit = $("input[name = 'unit']:checked").val();
	 var is_zs=$("input[name = 'is_zs']:checked").val();
	var status = $("input[name = 'status']:checked").val();
	 var ajax = new $ax(Feng.ctxPath + "/ZhMatchmakerLevel/update", function (data) {
	 	if ('00' === data.status) {
	 		Feng.success(data.msg,1000);
	 		window.parent.CodeGoods.table.refresh();
	 		CodeInfoDlg.close();
	 	} else {
	 		Feng.error(data.msg + "！",1000);
		 }
	 })
	 ajax.set('unit',unit);
	 ajax.set('status',status);
	 ajax.set('is_zs',is_zs);
	 ajax.set(this.CodeInfoData);
	 ajax.start();
};


</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
